Advertisement
Guest User

Untitled

a guest
Feb 4th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1.  
  2. // THIS DOES NOT WORK. IT WILL SKIP DATA:
  3. uint8_t SPI_SlaveReceive(void)
  4. {
  5.     while(!(SPSR0 & (1<<SPIF0)));
  6.     return SPDR0;
  7. }
  8.  
  9. // THIS WORK.
  10. // READ THE REGISTER 1st
  11. uint8_t SPI_SlaveReceive(void)
  12. {
  13.     uint8_t data = SPDR0;
  14.     while(!(SPSR0 & (1<<SPIF0)));
  15.     return data;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement